#7-4 罗马数字转换【组合数据类型】
def roman_to_int(s):
    roman_dict = {'I': 1, 'V': 5, 'X': 10, 'L': 50, 'C': 100, 'D': 500, 'M': 1000,
                  'IV': 4, 'IX': 9, 'XL': 40, 'XC': 90, 'CD': 400, 'CM': 900}
    result = 0
    i = 0
    while i < len(s):
        if i+1 < len(s) and s[i:i+2] in roman_dict:
            result += roman_dict[s[i:i+2]]
            i += 2
        else:
            result += roman_dict[s[i]]
            i += 1
    return result

# 输入罗马数字
num = input()
print(roman_to_int(num))